﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AnaxibiaStudios.BeanPermutator
{
  public class Iterator
  {
    public static Iterator<T> CreateFrom<T>(IPermute<T> permutator)
    {
      return new Iterator<T>(permutator);
    }
  }

  public class Iterator<T> : IEnumerable<IEnumerable<T>>, IEnumerator<IEnumerable<T>>
  {
    private IPermute<T> _permutator;

    public Iterator(IPermute<T> permutator)
    {
      _permutator = permutator;
    }

    public IEnumerator<IEnumerable<T>> GetEnumerator()
    {
      return this;
    }

    System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
    {
      return this;
    }

    public IEnumerable<T> Current
    {
      get { return _permutator.Current; }
    }

    public void Dispose() { }

    object System.Collections.IEnumerator.Current
    {
      get { return Current; }
    }

    public bool MoveNext()
    {
      return _permutator.MoveNext();
    }

    public void Reset()
    {
      _permutator.Reset();
    }
  }
}
